﻿
@{
    ViewBag.Title = "MasterBizTypeAdd";
    Layout = "~/Views/Shared/layoutCommon.cshtml";
}
@model OF.Component.Model.MasterBizTypeInfo

@section style{
    <style>
    .form-horizontal .control-label {
        width: 15%;
        float: left;
        text-align: right;
    }

    .col-sm-3 {
        width: 80%;
        float: left;
    }
</style>
}
<form class="form-horizontal" id="form1">
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="name">名称：</label>
                        <div class="col-sm-3">
                            <input type="text" maxlength="50" value="@Model.MasterBizTypeName" style="width:300px;" name="MasterBizTypeName" id="MasterBizTypeName" class="form-control" />
                        </div>
                    </div>
                </div>
                <div class="box-footer text-center">
                    <button class="btn btn-primary" type="button" id="btnSure">确 定 </button>
                    <button class="btn" type="button" id="btnCancel">取 消 </button>
                </div>


            </div>

        </div>
        <!-- /.row -->
    </section>
</form>
@section scriptsBottom{
    <script type="text/javascript">
        $(document).ready(function () {
            initFormValidate();
            $("#btnSure").click(function () {
                save();
            });
            $("#btnCancel").click(function () {
                BMCW.closeTopLayer();
            });
        });

        function initFormValidate()
        {
              $("#form1").bootstrapValidator({
                submitHandler: function (valiadtor, loginForm, submitButton) {
                    valiadtor.defaultSubmit();
                },
                fields: {
                    MasterBizTypeName: {
                        validators: {
                            notEmpty: {
                                message: '名称不能为空'
                            },
                            stringLength: {
                                /*长度提示*/
                                min: 1,
                                max: 50,
                                message: '名称长度必须在1到50之间'
                            }
                        }
                    }

                }
            });
        }

        function save() {
            var bootstrapValidator = $("#form1").data('bootstrapValidator');
            bootstrapValidator.validate();
            if (bootstrapValidator.isValid()) {
                var url = '@Url.Action("SaveMasterBizType", "BasicData")'
                BMCW.ajax({
                    url: url,
                    type: "Post",
                    data: {
                        MasterBizTypeID:@Model.MasterBizTypeID,
                        MasterBizTypeName: $("#MasterBizTypeName").val()
                    },
                    success: function (o) {
                        if (o.status == 0) {
                            BMCW.msg("保存成功",function(){
                                BMCW.getTopSelectedWin().search();
                            });
                        } else {
                            BMCW.alert("保存失败");
                        }
                    }
                });

            }
        }

    </script>
}